<template>
  <div class="header-bar">
    <sider-trigger v-show="showTrigger" :collapsed="collapsed" icon="md-menu" @on-change="handleCollpasedChange"></sider-trigger>
    <custom-bread-crumb v-show="showCrumb" show-icon style="margin-left: 16px;" :list="breadCrumbList"></custom-bread-crumb>
    <div class="custom-content-con">
      <slot></slot>
    </div>
  </div>
</template>

<script>
import siderTrigger from './sider-trigger'
import customBreadCrumb from './custom-bread-crumb'
import { filterTree } from '@/libs/util'
import './header-bar.styl'
export default {
  name: 'HeaderBar',
  components: {
    siderTrigger,
    customBreadCrumb
  },
  props: {
    collapsed: Boolean
  },
  data () {
    return {
      // showTrigger: false,
      // showCrumb: false
    }
  },
  computed: {
    windSize () {
      return this.$store.state.app.windowSize
    },
    apiNav () {
      return this.$store.state.user.apiNav
    },
    currentTabs () {
      return this.$store.state.user.currentTabs
    },
    breadCrumbList () {
      // return this.$store.state.app.breadCrumbList
      let arr = filterTree(this.apiNav, this.currentTabs)
      return [...this.$store.state.user.iframeRoutes.filter(item => arr.indexOf(item.name) !== -1)].reverse()
    },
    showTrigger () {
      return this.windSize.width > 800
    },
    showCrumb () {
      return this.windSize.width > 800
    }
  },
  methods: {
    handleCollpasedChange (state) {
      this.$emit('on-coll-change', state)
    }
  }
}
</script>
